<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of loadheader
 *
 * @author sonUIT
 */
class autogenid extends CI_Controller {

    //put your code here
    public function __construct() {
        parent::__construct();
    }

  
    
    /**
     *
     * Gen ID
     *
     * $pre    Tiền tố
     * $beforeID ID lớn nhất hiện tại
     * @return   ID được sinh ra
     *
     */
    public function genID($pre,$beforeID)
    {
        $temp=  strlen($beforeID);
        $numID=  intval(str_replace($pre,'',$beforeID))+1;
        $len=  $temp- strlen($numID)-  strlen($pre);
        $ID=$pre;
        $i=0;
        for($i=0;$i<$len;$i++)
        {
            $ID=$ID.'0';
        }
        $ID=$ID.$numID;
        return $ID;
      
    }

}
/* End of file autogenid.php */
